'''
Created on 13-Jul-2010

@author: asa
'''
import time
import Rating

class Contribution:
    
    def __init__(self):
        self.contributors = [ ]
        self.timestamp = time.time()
        self.rating = { }
    
    def getTotalRating(self):
        total = 0;
        for c, r in self.rating:
            total += r.rating
        return total
    
    def getAverageRating(self):
        total = self.getTotalRating()
        if total == 0:
            return 0
        else:
            return total / len(self.rating)
    
    def addContributor(self, contributor):
        self.contributors.append(contributor)
    
    def addRating(self, rater, rating):
        self.rating[rater] = Rating(rater, rating)
